myFocuserPro2Mini Windows Application ChangeLog

// (c) Copyright Robert Brown 2014-2020. All Rights Reserved.
// The schematic, code and ideas for myFocuser are released into the public domain. Users are free to implement
// these but may NOT sell this project or projects based on this project for commercial gain without express 
// written permission granted from the author. Schematics, Code, Firmware, Ideas, Applications, Layout are 
// protected by Copyright Law.
// Permission is NOT granted to any person to redistribute, market, manufacture or sell for commercial gain 
// the myFocuserPro2 products, ideas, circuits, builds, variations and units described or discussed herein or 
// on this site.
// Permission is granted for personal and Educational/Academic use only.

// 2.3.5.2
// Extend Certificate

// 2.3.5.1
// Implement keep alive timer
// Fix bug update lcd when moving
// remove motorspeedchange threshold and enable from extra settings page

// 2.3.5.0
// Fix bug in save/restore settings for DisplayMode
// Add check for form position on startup to determine if outside screen boundary
// Add a 5s interval to refresh temperature timer
// Fix bug in updating position when moving (if enabled in application)

// 2.3.4.9
// delayaftermove, threshold, bl steps in/out now 0-255
// temperature coefficient now 0-400

// 2.3.4.8
// Fix logging issue when connected to myFP2E controllers
// Fix not sending backlash settings to myFP2E controllers when in Local Serial Mode
// Fix issues of not retrieving some values from myFP2E controllers

// 2.3.4.7
// Add fix for using VCP CP2102 Virtual Com Port drivers for myFocuserPro2E

// 2.3.4.6
// Add checking for backlash steps

// 2.3.4.5
// Add get stepper power to MISC commands

// 2.3.4.4
// Add Update On Connect checkbox for MotorSpeed - Prepare for firmware 279

// 2.3.4.3
// add support for myFocuserPro2M assembled focusers
// display returned stepmode value when Get stepmode is clicked
// Send status of extrasettings update pos when moving - on Connect to controller
// fix logging of error messages upon exception [sometimes ignored]
// add temp comp direction [requires firmware 278 or higher]

// 2.3.4.1
// Fix bug in temp C and F

// 2.3.4.0 13082018
// Improve error handling for serial IO, catch disconnections
// New signed certificate valid to 11-August-2023
// Windows Sounds assigned to Refresh timers for Temperature and Position
// Bug fixes

// 2.3.3.9 09082018
// Rewrite serial IO
// remove stats
// add position and temp timers with configurable intervals and logfiles
// change way jogbar works, add jogging timer to retrieve position when jogging
// disable jogbar if moving
// Improve logging messages
// prevent refresh timers issuing call if a command is already in progress
// tidy up log messages
// implement position and temperature logging with refresh timers
// Prevent moves when temperature compensation is on
// Rewrite refreshing/updating, use separate timers for position and temperature
// Change refresh rates for auto updates
// Fix bug in step mode

// 2.3.3.8 16072018
// Fix bug in get temp comp settings
// Set focus to halt button during moves
// Fix bug in refresh timer for position not being set correctly
// Increase status message box size to two lines
// Reduce length of some status messages
// Add mutex around serial comms
// Add a refresh timer that will retreive current focuser position every 5, 10, or 30s
// Added to extrasettings form, values remembered
// Allow moves when temperature compensation is on
// Improve error logging messages
// Add temperature compensation ability - ON/OFF and status
// Fix bug in jogging + slow
// Fix bug in get maximum backlash steps

// 2.3.3.6 13032018
// Fix double reset of controller when connecting
// Remove backlash max 

// 2.3.3.5 12022018
// Rewrite focuser move button method
// Rewrite GotoPos methods
// Rewrite IsMoving method

// 2.3.3.4 24012018
// Minor bug fixes
// Improve status messages
// Add Misc Commands on settings menu

// 2.3.3.3 18122017
// Add "Is Controller A Micro" checkbox to settings form
// add backlash compensation
// Change application locale to eng-us

// 2.3.3.2 03122017
// Change application locale to eng-us

// 2.3.3.1 19112017
// Add DelayAfterMove support for firmware 259 upwards
// Fix bug in clear status msg bar
// Fix #47 timeout errors

// 2.3.2.9 10042017
// Validate and round tempoffset on application start

// 2.3.2.8 10072017
// Major rewrite of code for stepsize and other settings on Settings form
// Major rewrite of code for temp offset on main form

// 2.3.2.6 06072017
// Fix to allow stepsize to be Windows locale independent

// 2.3.2.5 09042017
// Write windows application version to logfile when connecting

// 2.3.2.4 05042017
// Fix for log file not working correctly in sub-folders
// Change reset logfile path so that application is forced to restart 

// 2.3.2.3 01032017
// Add confirm dialog box on Set Position and Set Max Position - 
// This behaviour can be enabled/disabled on the Extra Settings form when disconnected

// 2.3.2.2 16022017
// Add goto buttons for each preset on presets form
// Fix issue related to Focuser position text sometimes shown in gray
// Clear Serial buffer before re-connecting - intermittent issue if connection failed and was retried
//  - would sometimes fail again and only recourse was to restart application
// Add ability to set and get maxSteps value
// Add Max Focuser Limit to settings form so can specify maximum travel position in steps
// Maxfocuser limit is bound checked at 2048 - 2000000000. If error, then set to 2000000000
// Fix code to show focuser position in Application when moving - checkbox code was omitted

// 2.3.2.1 09012016
// Added extra checkbox on Extra Settings form to enable/disable rest on connect
// Fix for controller going into indeterminate state when application disconnects
// CPU Timing retreived (code ready for next controller firmware release)

// 2.3.2.0 07112016
// Add get focuser position when doing automatic temperature updates
// Fix for Auto TempTimer menu settings not being initialized or remembered
// Add support URL 

// 2.3.1.9 18102016
// Remember form location

// 2.3.1.8 14102016
// Fix bug in clearing the focuser position text box and clicking GOTO Position causes a crash
// Fix bug in switching between Celsius and Fahrenheit

// 2.3.1.7 30092016
// validation of stepsize 0.01-50.0, if invalid will default to 50.0
// Add checkbox on ExtraSettings form to enable/disable update of focuser position when moving (in main app form)
// Add code to handle focuser position update in waitonfocusermove - covers GOTO position and presets
// Added temperature compensation (enable/disable and get settings)
// Fix incorrect state of Motorspeed shown in menu on startup

// 2.3.1.6 24092016
// Restore LCDEnabled state and menus when starting application, and send state to controller when connecting
// Fix stepsize for values between 0 and 1

// 2.3.1.5 21092016
// renamed STOP button as HALT - same as in main application
// Added status message text line so can remove most of the warning pop up message boxes
// Add timer to clear status messages after timed interval (5s)
// Standardised exception handling in various places
// Added support for larger maxStep and position values
// Preset positions now range checked

/ 2.3.1.2 01092016
// Fix disconnection error - unable to disconnect when serial comms lost
// When serial comms is lost during session (such as unplugging cable) - app now goes into disconnected state
// Ensure disconnection if timer is automated and serial comms is lost

// 2.3.1.1 29082016
// Fix for app staying resident in memory after closing (rare occurrence)
// Fix bug in save/restore app settings

// 2.3.1.0 16082016
// Change in Exit() code when trying to exit whilst still connected - now gives option via dialog box
// Code replicated into Exit menu and Form Window X
// Fix to set MotorSpeedChange value and enable when connecting and update of menu values

// 2.3.0.9 03082016
// Fixed error in +50 steps

// 2.3.0.8 11072016
// Add EEPROM Writes to menu setting
// Add Get Status of Controller Display to menu setting - updates menu setting as checked/unchecked
// When starting for first time, copy drive path for settings file into dialog box - same as errorlog file

// 2.3.0.6 19072016
// Ensure when logging is disabled a logfile is not created on load

// 2.3.0.4 04062016
// Change Company/PublisherName to myFocuserPro and Product Name to myFocuserProMini

// 03062016 2.3.0.4
// Added presets 5-8
// Added extra code to clear preset labels at same time as clearing preset positions
// Changed back colors of Connect, Disconnect and Exit buttons

// 31052016 2.3.0.3
// Code changes to moving focuser, ismoving, presets, etc ported from main app
// Add check if focuser moving on settings menu
// Add jog control and jog control info on settings menu
// Add focuser moving check to  Save Restore options
// Fix for Celsius/Fahrenheit
// Fix for temperature precision
// Fixes for MotorSpeed, MotorSpeedChange value and status
// After connecting, Disconnect button will flash and computer will Beep - indicating connection successful

// 14052016 2.3.0.0
// Save timer tick box state so it is remembered and activated after connect if enabled
// Add settings menu check for get status of homeposition switch
// Write focuser default settings - use this after an upgrade of the controller firmware
// Enforce timeout checks on all received commands, if no response then disconnect focuser
// Kill any remaining active threads on application exit
// Add commands to enable update of lcd when moving
// Add checking and do not send commands if focuser is moving
// New protocol based on switch() - much faster, for use with Arduino firmware 230+
// Get motorspeed updates settings menu
// Lots of other minor fixes
// Expanded menu options under settings-MotorSpeed
// Changed delayconnect value to 2s default, accepts number between 2 and 10
// Added Write EEPROM setting menu option
// Additional logging messages
// Time taken to connect and retreive all parameters at 9600bps = 3 seconds
// Support for motor speed change - as it nears target it slows to slowspeed
// Motor speed change can be enabled/disabled from settings menu
// Motor speed distance threshold (in steps) to slowdown is user configurable (50-200)
// An exception error (no response, timeout, conversion) now disconnects focuser and logs error message


// 19042016 2.1.3.4
// Major changes
// Add reset arduino option on setting
// Reset size of temp box to handle up to 3 decimal places
// Removed prior features for setting templcdupdate and tempwait time as the arduino
// code no longer requires this - use v244.ino or greater


// 08042016 2.1.3.1
// Added ability to change temperature resolution of ds18b20 probe

// 31032016 2.1.2.9
// Implemented Serial Port speed setting - must match setting in Arduino Firmware for myFocuserPro2
// Default is 9600.
// Added exception handling for SerialTimeout when writing to ComPort (was handled elsewhere)

/// 21032016 2.1.2.8
// Fixed bug in stepsizeenabled

/ 18022016 2.1.2.5
// Implemented stepsize setting in controller v219 and higher
// You will find this on the ExtraSettings form
// Added commands
// :GT#		Txxxxx#		get step size in microns (if enabled by controller)
// :GU#		Ux#		    get if stepsize is enabled in controller (true or false, 0/1)
// :ST0#	None		set the return of user specified stepsize to be OFF - default
// :ST1#	None		set the return of user specified stepsize to be ON - reports what user specified as stepsize
// :SZXXXX#	None		set step size (microns) in controller, float format , eg 4.2
// Added message boxes if command is tried to sent and controller is not connected

// 16022016 2.1.2.3
// Add support for
// :SL0# Set lcdtempupdating to false, disable auto updating of temp on LCD display
// :SL1# Set lcdtempupdating to true, enable auto updating of temp on LCD display
// :SDxxxxx# set the tempconversioninterval setting (5000-15000) - length of time to refresh temperature when lcdtempupdating is true

// 05022016 2.1.2.0
// Fixed error in setting controller to Fahrenheit
// Have ordered settings menu from A-Z

// 31012016 2.1.1.9
// Changes for Win10 compatibility

// 26012016 2.1.1.8
// added capability to set the length of time that each lcd screen is displayed for, new menu setting added

// 30122015 2.1.1.7
// Fixed bug in errorlogging - state was not being remembered between sessions
// Fixed bug in StepMode - was wrongly being affected by Celsius code
// Reduced values of delay loops on Serial port reading and sending data
// changes to stepmode - listbox and button, introduced new check under settings - can be disabled or enabled, default - warning enabled
// warns if a change is attempted to stepmode when the focuser is connected. Remember that stepmode is a saved setting in the controller
// so changes should NOT be necessary once the focuser has been set up correctly.
// To change stepmode, select new value from dropdown list and then click Set Stepmode button. It not changed then original value is restored

// 15122015 2.1.1.6
// Single instance check on startup, only one instance can run at a time
// Cleaned up errorlogging
// code also in program.cs

// 14122015 2.1.1.4
// Application remembers MotorSpeed setting and is now sent to controller on connect

// 11122015 2.1.1.3
// Saves window locations and sizes, hold down shift to override
// Disable resizing of windows form and sub-forms
// Fixed errors if trying to display sub-forms more than once
// fixed bug in C/F on Load and Disconnect

// 01122015 2.1.1.2
// fixed when connecting to invalid comport or controller
// set default temp to 20.0 on startup
// the firmware version will be written to the errorlog when connected
// changed serial initialization code, will connect if 12V is ON first
// clear textboxes when button is pressed
// temperature value when disconnecting and loading now reflects c/f status
// added firmware version to About() menu

// 07112015 2.1.1.0
// Temperature can be either celsius or fahrenheit
// cleaned up log messages

// 29102015 2.1.0.7
// Support for MaxIncrement added
// Fix for temp wait delay issue, change of protocol to GW/SW

// 28102015 2.1.0.5
// Support for RAPS128 driver board, stepmode to 1/128
// Focuser Maximum Pos = 65000

// 22102015 2.1.0.4
// changes to force exit()
// Removed startup dialog box

// 23092015 2.1.0.2
// Fixed error when installing, exits after setting errorlog path
// error in Load() change to elogpathfrm.ShowDialog

// 02092015 2.1.0.1
// Implemented LastTempReading in GetTemp() - helps reduce serial traffic - WBPFM
// Obeys DelayTempCalls waiting time 
// Added ability to set the tempwaitdelay between successive temperature requests, 2000-10000
// Default is 5000, expressed in milliseconds, saved in the controller EEPROM v146 and abpve
// appears on ExtraSettings form
// Added additional parametrs on ExtraSettings form, delay on connect, timeout on serial read
// Added DelayOnConnect application setting
// Added ReadTimeOutWait application setting
// Added DelayTempCalls application setting
// On Connect clear all the textboxes, grey tempoffset
// On Disconnect clear all the text boxes, grey tempoffset
// When connected, connect button disabled, disconnect enabled etc
// When disconnected, connect button enabled, disconnect disabled etc
// Use published application version rather than static version string

// 27082015 2.1.0.0
// Rewrite the exit events, now will not let application exit if serial port is connected

// 27082015 2.0.12.09
// Fix to ensure error does not occur if close occurs in the middle of a command about to execute
// FormClosing() also modified to display warning popup

// 27082015 2.0.12.08
// changes to GetTempPath(), Logmessagetofile - can now specify folder and it is remembered
// fixed bug in logmessages ending in .
// moved tooltips to a function
// added errorlogpath form to handle folder for log file

// 02082015 2.0.12.07
// changed icon file

// 10072015 2.0.12.06
// fixed bug in dim values maxsteps, had to turn off readonly for tempbox and maxsteps

// 10072015 2.0.12.05
// added link to sourceforge site on settings menu and in copyright screen
// On disconnect, dim values in Focuser Position, Maximum Position, Temp Offset
// on connect, reset color of text in Focuser Position, Maximum Position, Temp Offset

// 02072015 2.0.12.03
// Add copy current focuser position to presets on subform settings
// Focuser position textbox set to application settings so can be 
// accessed from subform when copying current focuser position to a preset
// Added focuser presets on a subform settings, and added to settings menu

// 27062015 2.0.12.02
// Moved CoilPwr, ReverseDir, StepMode, UseTFT checkboxes and code to main form
// Fixed bug in CoilPwr

// 25062015 2.0.12.01
// Added readtimeoutwait # of seconds to wait for response after sending command to controller

// 16062015 2.0.11.09
// Added validation to DelayOnConnect when Close button is clicked on Settings form

// 15062015 2.0.11.07
// Added on settings form ability to specify connect delay in seconds (4s-30s)
// Added some tips

// 14062015 2.0.11.01
// moved checkboxesto subform

// 13062015 v2.0.10.0
// fixed error in comport refresh

// 13062015 2.0.09.14
// changed appname to myFocuser2Mini

// 13062015 2.0.09.13
// add tool tips to focuser move buttons 

// 12062015 2.0.09.12 
// Initial release

// 11062015 2.0.09.6
// added system culture to temp offset box so user can use , as decimal seperator
// added validation and exception catching in temperature calls for temperature offset values
// updated date entry rules for text box entry for temp offset text box
